package com.mitake.task.dayK;

import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;

import com.mitake.parse.DayK;
import com.mitake.parse.DayK.DayKItem;
import com.mitake.utils.Util;

public class DayKCompareProcess {
	
	//public static ArrayList<DayK[]> store =new ArrayList<DayK[]>();
	
	public static DayK[] data = null;
	
	public static void compare(DayK[] dayKs){
		for(int i = 1, len = dayKs.length-1; i<len; i++){
			compareItem(dayKs, dayKs[i].dayKMap, dayKs[i+1].dayKMap);
		}
		//store.add(dayKs);
		data = dayKs;
	}
	
	private static void compareItem(DayK[] dayKs, Map<String,DayKItem> dayK_1,Map<String,DayKItem> dayK_2){
		for(String key : dayK_1.keySet()){
			 DayKItem dayKItem = dayKs[0].dayKMap.get(key);
			 if(dayKItem == null){
				 dayKItem =new DayKItem();
				 dayKs[0].dayKMap.put(key, dayKItem);
			 }
			if(Util.hasDifference(dayK_1.get(key).firstPrice, dayK_2.get(key).firstPrice)){
				dayKItem.lastPrice = "@";
			}
			if(Util.hasDifference(dayK_1.get(key).highPrice, dayK_2.get(key).highPrice)){
				dayKItem.lastPrice = "@";
			}
			if(Util.hasDifference(dayK_1.get(key).lowPrice, dayK_2.get(key).lowPrice)){
				dayKItem.lastPrice = "@";
			}
			if(Util.hasDifference(dayK_1.get(key).lastPrice, dayK_2.get(key).lastPrice)){
				dayKItem.lastPrice = "@";
			}
			if(Util.hasDifference(dayK_1.get(key).volume, dayK_2.get(key).volume)){
				dayKItem.volume = "@";
			}
			if(Util.hasDifference(dayK_1.get(key).reference, dayK_2.get(key).reference)){
				dayKItem.volume = "@";
			}
		}
	}
}
